package edu.uwlax.cs.oayonlinestore.server;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

import edu.uwlax.cs.oayonlinestore.ServiceLocator;
import edu.uwlax.cs.oayonlinestore.client.OnlinestoreRService;
import edu.uwlax.cs.oayonlinestore.exceptions.SerializableException;
import edu.uwlax.cs.oayonlinestore.vo.CategoryStructureVO;
import edu.uwlax.cs.oayonlinestore.vo.CategoryVO;
import edu.uwlax.cs.oayonlinestore.vo.GiftCardVO;
import edu.uwlax.cs.oayonlinestore.vo.InventoryReportVO;
import edu.uwlax.cs.oayonlinestore.vo.OrderEditVO;
import edu.uwlax.cs.oayonlinestore.vo.OrderExtendedVO;
import edu.uwlax.cs.oayonlinestore.vo.OrderSummaryVO;
import edu.uwlax.cs.oayonlinestore.vo.ProductDetailsVO;
import edu.uwlax.cs.oayonlinestore.vo.ProductPriceVO;
import edu.uwlax.cs.oayonlinestore.vo.RetExFormVO;
import edu.uwlax.cs.oayonlinestore.vo.SalesReportVO;
import edu.uwlax.cs.oayonlinestore.vo.SnapshotVO;
import edu.uwlax.cs.oayonlinestore.vo.SubcategoryVO;
import edu.uwlax.cs.oayonlinestore.vo.UserDetailsVO;
import edu.uwlax.cs.oayonlinestore.vo.UserVO;

public class OnlinestoreRServiceImpl extends RemoteServiceServlet implements
		OnlinestoreRService {

	private static final long serialVersionUID = 7253730643420508675L;

	public OnlinestoreRServiceImpl() {
		super();
		Session.setService(this);
	}

	public void addEditCategory(CategoryVO category) {
		ServiceLocator.instance().getOnlinestore().addEditCategory(category);
	}

	public void addEditProduct(ProductDetailsVO product, int subcategoryID) {
		ServiceLocator.instance().getOnlinestore().addEditProduct(product,
				subcategoryID);

	}

	public void addEditRetExForm(RetExFormVO retExForm, int orderItemID)
			throws SerializableException {
		ServiceLocator.instance().getOnlinestore().addEditRetExForm(retExForm,
				orderItemID);

	}

	public void addEditSubcategory(SubcategoryVO subcategory, int categoryID) {
		ServiceLocator.instance().getOnlinestore().addEditSubcategory(
				subcategory, categoryID);
	}

	public void addEditUser(UserDetailsVO user) {
		ServiceLocator.instance().getOnlinestore().addEditUser(user);
	}

	public void addGiftCardToOrder(int orderID, String cardID) {
		ServiceLocator.instance().getOnlinestore().addGiftCardToOrder(orderID,
				cardID);
	}

	public void addManagerToCategory(int categoryID, int userID) {
		ServiceLocator.instance().getOnlinestore().addManagerToCategory(
				categoryID, userID);
	}

	public void addProductToOrder(int productID, int quantity, int orderID) {
		ServiceLocator.instance().getOnlinestore().addProductToOrder(productID,
				quantity, orderID);
	}

	public void addStaffToCategory(int categoryID, int userID) {
		ServiceLocator.instance().getOnlinestore().addStaffToCategory(
				categoryID, userID);
	}

	public void approveIndustrialUser(int userID) {
		ServiceLocator.instance().getOnlinestore()
				.approveIndustrialUser(userID);
	}

	public void createSnapshot() throws SerializableException {
		ServiceLocator.instance().getOnlinestore().createSnapshot();

	}

	public void deleteGiftCard(int giftCardID) {
		ServiceLocator.instance().getOnlinestore().deleteGiftCard(giftCardID);
	}

	public void deleteOrderItem(int orderItemID) {
		ServiceLocator.instance().getOnlinestore().deleteOrderItem(orderItemID);
	}

	public void disableCategory(int categoryID) {
		ServiceLocator.instance().getOnlinestore().disableCategory(categoryID);
	}

	public void disableProduct(int productID) {
		ServiceLocator.instance().getOnlinestore().disableProduct(productID);
	}

	public void disableSubcategory(int subcategoryID) {
		ServiceLocator.instance().getOnlinestore().disableSubcategory(
				subcategoryID);
	}

	public void generateGiftCards(int count, int moneyValue) {
		ServiceLocator.instance().getOnlinestore().generateGiftCards(count,
				moneyValue);

	}

	public void generateTestData() {
		ServiceLocator.instance().getOnlinestore().generateTestData();
	}

	public UserVO[] getApprovableIndustrialUsers() {
		return ServiceLocator.instance().getOnlinestore()
				.getApprovableIndustrialUsers();
	}

	public CategoryVO getCategory(int categoryID) {
		return ServiceLocator.instance().getOnlinestore().getCategory(
				categoryID);
	}

	public CategoryVO[] getCategoryList() {
		return ServiceLocator.instance().getOnlinestore().getCategoryList();
	}

	public UserVO[] getCategoryManagerList(int categoryID) {
		return ServiceLocator.instance().getOnlinestore()
				.getCategoryManagerList(categoryID);
	}

	public UserVO[] getCategoryPeopleList() {
		return ServiceLocator.instance().getOnlinestore()
				.getCategoryPeopleList();
	}

	public UserVO[] getCategoryStaffList(int categoryID) {
		return ServiceLocator.instance().getOnlinestore().getCategoryStaffList(
				categoryID);
	}

	public CategoryStructureVO[] getCategoryStructureList() {
		return ServiceLocator.instance().getOnlinestore()
				.getCategoryStructureList();
	}

	public OrderSummaryVO getCurrentOrder() throws SerializableException {
		return ServiceLocator.instance().getOnlinestore().getCurrentOrder();
	}

	public CategoryVO[] getEditableCategoriesForCurrentUser() {
		return ServiceLocator.instance().getOnlinestore()
				.getEditableCategoriesForCurrentUser();
	}

	public GiftCardVO[] getGiftCardList() {
		return ServiceLocator.instance().getOnlinestore().getGiftCardList();
	}

	HttpServletRequest getHTTPRequest() {
		return getThreadLocalRequest();
	}

	HttpServletResponse getHTTPResponse() {
		return getThreadLocalResponse();
	}

	public InventoryReportVO[] getInventoryReport(int snapshot1ID,
			int snapshot2ID) throws SerializableException {
		return ServiceLocator.instance().getOnlinestore().getInventoryReport(
				snapshot1ID, snapshot2ID);
	}

	public UserDetailsVO getLoggedInUser() {
		return ServiceLocator.instance().getOnlinestore().getLoggedInUser();
	}

	public OrderEditVO getOrderEdit(int orderID) {
		return ServiceLocator.instance().getOnlinestore().getOrderEdit(orderID);
	}

	public OrderExtendedVO getOrderExtended(int orderID) {
		return ServiceLocator.instance().getOnlinestore().getOrderExtended(
				orderID);
	}

	public OrderSummaryVO[] getOrdersByLastNameAndZip(String lastname, int zip) {
		return ServiceLocator.instance().getOnlinestore()
				.getOrdersByLastNameAndZip(lastname, zip);
	}

	public OrderSummaryVO[] getOrderSummaryList(int userID)
			throws SerializableException {
		return ServiceLocator.instance().getOnlinestore().getOrderSummaryList(
				userID);
	}

	public ProductDetailsVO[] getProductDetailList(int subcategoryID) {
		return ServiceLocator.instance().getOnlinestore().getProductDetailList(
				subcategoryID);
	}

	public RetExFormVO getRetExForm(int formID) throws SerializableException {
		return ServiceLocator.instance().getOnlinestore().getRetExForm(formID);
	}

	public RetExFormVO[] getRetExFormsList() {
		return ServiceLocator.instance().getOnlinestore().getRetExFormsList();
	}

	public SalesReportVO getSalesReport(Date date) {
		return ServiceLocator.instance().getOnlinestore().getSalesReport(date);
	}

	public SnapshotVO[] getSnapshotList() throws SerializableException {
		return ServiceLocator.instance().getOnlinestore().getSnapshotList();
	}

	public SubcategoryVO[] getSubcategories(int categoryID) {
		return ServiceLocator.instance().getOnlinestore().getSubcategories(
				categoryID);
	}

	public UserDetailsVO getUserDetail(int userID) {
		return ServiceLocator.instance().getOnlinestore().getUserDetail(userID);
	}

	public UserDetailsVO[] getUserDetailList() {
		return ServiceLocator.instance().getOnlinestore().getUserDetailList();
	}

	public UserDetailsVO login(String login, String pwd) {
		return ServiceLocator.instance().getOnlinestore().login(login, pwd);
	}

	public UserDetailsVO logout() {
		return ServiceLocator.instance().getOnlinestore().logout();
	}

	public void placeOrder(int orderID) {
		ServiceLocator.instance().getOnlinestore().placeOrder(orderID);
	}

	public void removeGiftCardFromOrder(int orderID, int giftCardID) {
		ServiceLocator.instance().getOnlinestore().removeGiftCardFromOrder(
				orderID, giftCardID);
	}

	public void removeManagerFromCategory(int categoryID, int userID) {
		ServiceLocator.instance().getOnlinestore().removeManagerFromCategory(
				categoryID, userID);
	}

	public void removeStaffFromCategory(int categoryID, int userID) {
		ServiceLocator.instance().getOnlinestore().removeStaffFromCategory(
				categoryID, userID);
	}

	public void setCurrentOrder(int orderID) throws SerializableException {
		ServiceLocator.instance().getOnlinestore().setCurrentOrder(orderID);

	}

	public void setOrderItemAmount(int orderItemID, int ammount) {
		ServiceLocator.instance().getOnlinestore().setOrderItemAmount(
				orderItemID, ammount);
	}

	public void setProductPrices(ProductPriceVO product)
			throws SerializableException {
		ServiceLocator.instance().getOnlinestore().setProductPrices(product);

	}

	public void setUserInactive(int userID) {
		ServiceLocator.instance().getOnlinestore().setUserInactive(userID);
	}

	public void updateOrderEdit(OrderEditVO orderEdit, boolean storeCCInProfile) {
		ServiceLocator.instance().getOnlinestore().updateOrderEdit(orderEdit,
				storeCCInProfile);

	}

}
